package com.klun.aop.method;

public class MonitorSession {

    /* 使用本地线程防止多线程的共用资源信息 用threadlocal包装 */
    private static ThreadLocal<MethodMonitor> monitorThreadLocal = new ThreadLocal<>();

    public static void begin(String method) {
        System.out.println("MonitorSession:begin----当前线程"+Thread.currentThread().getName());
        MethodMonitor logger = new MethodMonitor(method);
        monitorThreadLocal.set(logger);
    }

    public static void end() {
        System.out.println("MonitorSession:end----当前线程"+Thread.currentThread().getName());
        MethodMonitor logger = monitorThreadLocal.get();
        logger.log();
    }

}
